﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for SemiFinalRound
/// </summary>
public class SemiFinalRound
{
    public int TournamentID;
    public string TournamentName;
    public string PlayerNick;
    public int PlayerNumber;
    public int PlayerGroup;
    public int MachineNumber;
    public string MachineName;
    public Int64 Score;

    public static List<SemiFinalRound> GetSemiFinalRounds() {
        try
        {
            List<SemiFinalRound> SemiFinalRounds = new List<SemiFinalRound>(); 

            DataTable oDataTable = DataBase.dt("SELECT * FROM SemifinalsTournamentRounds");

            if (oDataTable.Rows.Count > 0)
            {
                foreach (DataRow iDataRow in oDataTable.Rows)
                {
                    SemiFinalRound oSemiFinalRound = new SemiFinalRound();
                    oSemiFinalRound.TournamentID = Int32.Parse(iDataRow["TournamentID"].ToString());
                    oSemiFinalRound.TournamentName = iDataRow.IsNull("TournamentName") ? string.Empty : iDataRow["TournamentName"].ToString();
                    oSemiFinalRound.PlayerNick = iDataRow.IsNull("PlayerNick")?string.Empty:iDataRow["PlayerNick"].ToString();
                    oSemiFinalRound.PlayerNumber = Int32.Parse(iDataRow.IsNull("PlayerNumber") ? "0" : iDataRow["PlayerNumber"].ToString());
                    oSemiFinalRound.PlayerGroup = Int32.Parse(iDataRow.IsNull("PlayerGroup") ? "0" : iDataRow["PlayerGroup"].ToString());
                    oSemiFinalRound.MachineNumber = Int32.Parse(iDataRow.IsNull("MachineNumber") ? "0" : iDataRow["MachineNumber"].ToString());
                    oSemiFinalRound.MachineName = iDataRow.IsNull("MachineName") ? string.Empty : iDataRow["MachineName"].ToString();
                    oSemiFinalRound.Score = Int64.Parse(iDataRow.IsNull("Score") ? "0" : iDataRow["Score"].ToString());
                    SemiFinalRounds.Add(oSemiFinalRound);
                }             
            }
            return SemiFinalRounds;
        }
        catch (Exception Ex) {
            return new List<SemiFinalRound>();
        }
    }

	public SemiFinalRound()
	{
        
	}
}